package com.chengqs.concurrent;

import org.openjdk.jcstress.annotations.*;
import org.openjdk.jcstress.infra.results.I_Result;

import java.util.concurrent.CountDownLatch;

@JCStressTest
@Outcome(id = "20", expect = Expect.ACCEPTABLE, desc = "ok")
@Outcome(id = "0", expect = Expect.ACCEPTABLE_INTERESTING, desc = "!!!")
@State
public class Main {

    volatile int x;
    int y;

    public Main() {
        System.out.println("Main instance created: " + this);
    }

    @Actor
    public void actor1(I_Result r) {
        System.out.println(x);
        r.r1 = x;
    }

    @Actor
    public void actor2(I_Result r) {
        y = 10;
        x = 20;
    }
}